IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UpdateAdvanceFundRequestUploadedDocumentMetadata]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[UpdateAdvanceFundRequestUploadedDocumentMetadata]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



--UpdateAdvanceFundRequestUploadedDocumentMetadata 11, 'http://stage-infoeddocuments.partners.org/proposals/2007/Documents/AdvanceFundRequest/12.txt', 1

CREATE PROCEDURE [dbo].[UpdateAdvanceFundRequestUploadedDocumentMetadata] 
(  
	@DocId	INT,
	@FileUrl	VARCHAR(500),
	@OpState	INT
)  
AS 

SET NOCOUNT ON
		
		IF(@OpState = 0)
		BEGIN
	
			DELETE FROM dbo.AdvanceFundRequestUploadedDocument
			WHERE Id = @DocId

		END
		ELSE
		BEGIN

			UPDATE dbo.AdvanceFundRequestUploadedDocument SET FileUrl = @FileUrl
			WHERE Id = @DocId

		END


GO